1 package com.fc.taglibs.castor.integration.tomcat;
2
3 import java.net.URL;
4 import java.util.Hashtable;
5 import javax.naming.Name;
6 import javax.naming.Context;
7 import javax.naming.NamingException;
8 import javax.naming.Reference;
9 import javax.naming.RefAddr;
10 import javax.naming.spi.ObjectFactory;
11 import javax.transaction.TransactionManager;
12
13 import tyrex.tm.TransactionDomain;
14
15 import org.apache.naming.factory.TyrexFactory;
16
17 public class TyrexTransactionManagerFactory
18 extends TyrexFactory {
19
20 /***
21 * Crete a new TransactionManager.
22 *
23 * @param obj The reference object
24 */
25 public Object getObjectInstance(Object obj, Name name, Context nameCtx,
26 Hashtable environment)
27 throws NamingException
28 {
29
30 Reference ref = (Reference) obj;
31 if (ref.getClassName()
32 .equals("javax.transaction.TransactionManager"))
33 {
34 try
35 {
36 return getTransactionDomain().getTransactionManager();
37 }
38 catch (Throwable t)
39 {
40 log("Cannot create TransactionManager, Exception", t);
41 throw new NamingException
42 ("Exception creating TransactionManager: " + t.getMessage());
43 }
44
45 }
46
47
48 return null;
49
50 }
51
52
53 private void log(String message) {
54 System.out.print("TyrexTransactionManagerFactory: ");
55 System.out.println(message);
56 }
57
58
59 private void log(String message, Throwable exception) {
60 log(message);
61 exception.printStackTrace(System.out);
62 }
63
64
65 }
66
This page was automatically generated by Maven